home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / science / sm32a.zip / LIBRARY / PLOT2Y.LI < prev    next >
Text File  |  1994-07-22  |  934b  |  29 lines

  1. #  library plot2y
  2. #  plot2y(y,y2,x)
  3. #  plots two functions of y=y(x) and y2=y2(x) on the same graph
  4. #  on xy-plane by default xmin:=-5, xmax:=5, ymin:=-5, ymax:=5
  5. #  It graphically solves a system of 2 equations so a cross of 2 curves 
  6. #  is a solution.
  7. #  e.g. plot2y(x^2-1,x+1,x)
  8.  
  9. plot2y(y_, y2_, x_, xmin_, xmax_, ymin_, ymax_) := block(numeric:=on,
  10.     graph,
  11.     dx:=(xmax-xmin)/getmaxx,
  12.     dy:=(ymax-ymin)/getmaxy,
  13.     xstep:=dx*10,
  14.     axis(xmin,xmax,ymin,ymax),
  15.     setcolor(colorno(yellow)),
  16.     moveto(0,getmaxy-(subs(y,x=xmin)-ymin)/dy),
  17.     do( lineto((x-xmin)/dx,getmaxy-(y-ymin)/dy),
  18.     x,xmin,xmax,xstep),
  19.     setcolor(colorno(green)),
  20.     moveto(0,getmaxy-(subs(y2,x=xmin)-ymin)/dy),
  21.     do( lineto((x-xmin)/dx,getmaxy-(y2-ymin)/dy),
  22.     x,xmin,xmax,xstep),
  23.     numeric:=off,
  24.     readchar,
  25.     text,
  26.     local(dx,dy,xstep))
  27. plot2y(y_, y2_, x_, xmin_, xmax_) := plot2y(y,y2,x,xmin,xmax,-5,5)
  28. plot2y(y_, y2_, x_) := plot2y(y,y2,x,-5,5,-5,5)
  29.